package com.zut.subject.domain.handler.subject;

import com.zut.subject.common.enums.IsDeletedFlagEnum;
import com.zut.subject.common.enums.SubjectTypeEnum;
import com.zut.subject.domain.convert.ConvertSubjectType;
import com.zut.subject.domain.entity.SubjectInfoBo;
import com.zut.subject.domain.entity.SubjectOptionAnswerBo;
import com.zut.subject.infra.basic.entity.SubjectBrief;
import com.zut.subject.infra.basic.entity.SubjectJudge;
import com.zut.subject.infra.basic.service.SubjectBriefService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Slf4j
public class BriefSubjectTypeHandlerImpl implements SubjectTypeHandler {

    @Resource
    private SubjectBriefService subjectBriefService;

    @Override
    public SubjectTypeEnum subjectEnum() {

        return SubjectTypeEnum.BRIEF;
    }

    @Override
    public void add(SubjectInfoBo subjectInfoBo) {

        //简答题逻辑
        String subjectAnswer = subjectInfoBo.getSubjectAnswer();
        SubjectBrief subjectBrief =new SubjectBrief();
        subjectBrief.setIsDelete(IsDeletedFlagEnum.UN_DELETED.getCode());
        subjectBrief.setSubjectAnswer(subjectAnswer);
        subjectBrief.setSubjectId(subjectInfoBo.getId());
        subjectBriefService.insert(subjectBrief);

    }

    @Override
    public SubjectInfoBo querySubjectOption(Integer subjectId) {
        SubjectBrief subjectBrief = subjectBriefService.queryById(subjectId);
        SubjectInfoBo subjectInfoBo =new SubjectInfoBo();
        subjectInfoBo.setSubjectAnswer(subjectBrief.getSubjectAnswer());
        return subjectInfoBo;
    }
}
